using Circus.Syntax.Lexer;
using System;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Globalization;
using System.Reflection;
namespace Circus.Syntax.Design
{
	public class LexSchemeConverter : TypeConverter
	{
		public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
		{
			return destinationType == typeof(InstanceDescriptor) || base.CanConvertTo(context, destinationType);
		}
		public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
		{
			object result;
			if (destinationType == typeof(InstanceDescriptor) && typeof(LexScheme).IsInstanceOfType(value))
			{
				ConstructorInfo constructor = typeof(LexScheme).GetConstructor(new Type[0]);
				if (constructor != null)
				{
					result = new InstanceDescriptor(constructor, null, false);
					return result;
				}
			}
			result = base.ConvertTo(context, culture, value, destinationType);
			return result;
		}
	}
}
